#include "PDTAssign.h"
#include "PDTCodeGraph.h"


void PDTAssign::setTarget(PDTVar &target){

//	&((PDTNode&)target);
//	target.getNode()
	readers[0]=target.getNode();
	readers[0]->addWriter(this);

	addChild(readers[0]);
	readers[0]->addParent(this);

}

void PDTAssign::setExpression(PDTExp &expression){

	writers[0]=&expression;
	expression.addReader(this);
	addChild(&expression);
	expression.addParent(this);

}

PDTVar * PDTAssign::getTarget(){
	return dynamic_cast<PDTVar*>(readers[0]);

}

PDTExp * PDTAssign::getExpression(){
	return dynamic_cast<PDTExp*>(writers[0]);

}


PDTAssign::PDTAssign(PDTCodeGraph & CG,PDTVar &target,PDTExp &expression):PDTStatement(CG){
//	PDTNode& temp = (PDTNode&)target;
//	temp.addWriter(this);

	PDTNode* varNode = target.getNode();
	addReader(varNode);
	varNode->addWriter(this);
	varNode->addParent(this);
	addChild(varNode);

	addWriter(&expression);
	expression.addReader(this);
	addChild(&expression);
	expression.addParent(this);

}
